package com.authsphere.plugin.decrypt;

import com.authsphere.common.enums.AlgorithmType;
import com.google.common.collect.Maps;

import java.util.Map;

/**
 * @program: AuthSphere
 * @description:
 * @author: YuKai Fan
 * @create: 2025/3/28 11:30
 **/
public class RequestBodyDecoderFactory {

    private final static Map<AlgorithmType, RequestBodyDecoder> FACTORY_MAP = Maps.newConcurrentMap();

    static {
        FACTORY_MAP.put(AlgorithmType.AES, new AesRequestBodyDecoder());
        FACTORY_MAP.put(AlgorithmType.RSA, new RsaRequestBodyDecoder());
        FACTORY_MAP.put(AlgorithmType.JWT, new JwtRequestBodyDecoder());
        FACTORY_MAP.put(AlgorithmType.NONE, NoneRequestBodyDecoder.INSTANCE);
    }

    public static RequestBodyDecoder getInstance(AlgorithmType algorithmType) {
        return FACTORY_MAP.getOrDefault(algorithmType, NoneRequestBodyDecoder.INSTANCE);
    }
}
